package net.xfok.info.xinfo;

import android.app.Activity;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.util.Log;
import android.webkit.WebSettings;
import android.webkit.WebViewClient;
import android.widget.Toast;


public class XInfo extends Activity {
	private final static String URL="http://www.xfok.net/xInfos/wap/";
    /** Called when the activity is first created. */
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);    
        setContentView(R.layout.main);          
        android.webkit.WebView wv;	        
        wv = (android.webkit.WebView) findViewById(R.id.world_news);
        WebSettings webSettings = wv.getSettings();
		webSettings.setJavaScriptEnabled(true);
		wv.setWebViewClient(new WebViewClient());
        if(checkNet(this)){
        	wv.loadUrl(URL); 
        }else{
        	finish();
        }
    }
    
    public  boolean checkNet(Context context){
		boolean result=false;
		ConnectivityManager cm=(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo netinfo = cm.getActiveNetworkInfo();
		if ( netinfo !=null&&netinfo.isConnected() ) {
			result=true;
			Log.i( context.getClass().getName(), "The net was connected" );
		}else{
			Toast.makeText(context,context.getResources().getText(R.string.dialog_message_net_not), Toast.LENGTH_LONG).show();		
		}
		return result;
	}
}